<template>
  <div class="viewCustomerDetails">
    <div class="header-top">
      <div class="head-title" @click="gotoPage">
        <div class="backIcon"><i class="el-icon-back"></i></div>任务中心
      </div>
    </div>
    <div class="content-main">
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="130px">
        <el-form-item prop="userName4">
          <div class="right-big">
            <span>类型：</span>
            <el-select
                v-model="queryParams.userName4"
                @change="handleQuery"
                placeholder="请选择所属企微号"
            >
              <el-option
                  v-for="item in WeChatList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
              >
              </el-option>
            </el-select>
          </div>
        </el-form-item>
        <el-form-item prop="userName5">
          <div class="right-big">
            <span>状态：</span>
            <el-select
                v-model="queryParams.userName5"
                @change="handleQuery"
                placeholder="请选择状态"
            >
              <el-option
                  v-for="item in WeChatList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
              >
              </el-option>
            </el-select>
          </div>
        </el-form-item>
        <el-form-item>
          <div class="right-big">
            <span>添加时间：</span>
            <el-date-picker
                v-model="dateRange2"
                value-format="yyyy-MM-dd HH:mm:ss"
                type="datetimerange"
                range-separator="-"
                start-placeholder="开始时间"
                end-placeholder="结束时间"
                @change="handleQuery"
            ></el-date-picker>
          </div>
        </el-form-item>
      </el-form>
      <el-table
          :data="tableDataList"
          ref="customerMgtList"
      >
        <el-table-column
            :label="item.label"
            align="center"
            v-for="(item, index) in tableColumns"
            :key="index"
            :prop="item.key"
            :min-width="item.minWidth ? item.minWidth : ``"
            :fixed="item.fixed ? item.fixed : false"
            :show-overflow-tooltip="true"
        >
          <!--用于表格自定义-->
          <template slot-scope="scope">
            <div class="group-btn" v-if="item.key =='operate'">
              <el-button type="text">详情</el-button>
            </div>
            <div v-else>{{ scope.row[item.key] }}</div>
          </template>
        </el-table-column>
      </el-table>
      <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
      />
    </div>
  </div>
</template>

<script>
import {listUser} from "@/api/system/user";

export default {
  name: 'taskList',
  components: {

  },
  data() {
    return {
      // 查询参数
      dateRange1:[],
      dateRange2:[],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userName1: null,
        userName2: null,
        userName3: null,
        userName4: null,
        userName5: null,
        userName6: null,
        userName7: null,
        userName8: null,
        userName9: null,
        userName10: null,
        userName11: null,
        userName12: null,
        userName13: null,
        userName14: null,
      },
      tableHeight:600,
      WeChatList: [
        //所属企微号
        {id: 1, name: "技术部"},
        {id: 2, name: "人事部"},
      ],
      tableColumns: [
        {key: 'name', label: `任务提交时间`, visible: true, minWidth: 150, fixed: true},
        {key: 'mobile', label: `任务类型`, visible: true, minWidth: 150, fixed: false},
        {key: 'email', label: `任务状态`, visible: true, minWidth: 200},
        {key: 'last_login_time', label: `任务对象数`, visible: true, minWidth: 200},
        {key: 'create_time', label: `任务标签数`, visible: true, minWidth: 200},
        {key: 'check_payCreate_time', label: `已完成对象数`, visible: true, minWidth: 200},
        {key: 'check_payStatus_name', label: `已完成标签数`, visible: true, minWidth: 150},
        {key: 'account_infoStatus_name', label: `操作者`, visible: true, minWidth: 150},
        {key: 'operate', label: `操作`, visible: true, minWidth: 250,fixed: 'right',},
      ],
      tableDataList: [],
      total: 8, // 表格的总条数
    }
  },
  created() {
    this.getList();
    this.tableDataList=[];
    for (let i=0; i<10;i++){
      let obj={
        name:'小红',
        mobile:'18207418337',
        email:'2572513931@qq.com',
        last_login_time:'锐行科技',
        create_time:'2012-02-12',
        check_payCreate_time:'一般',
        check_payStatus_name:'核心',
        account_infoStatus_name:'2012-09-13',
        all_num:'微信',
        open_num:'一般',
        check_num:'2012-09-12',
        waiting_coin:'2012-08-23',
        operate:true,
      }
      this.tableDataList.push(obj);
    }
  },
  mounted() {
  },
  watch: {},
  methods: {

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.queryParams.deptId = undefined;
      this.handleQuery();
    },
    /** 查询用户列表 */
    getList() {
      this.loading = true;
      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
            this.userList = response.rows;
            this.total = response.total;
            this.loading = false;
          }
      );
    },
    gotoPage() {
      this.$router.push({
        name: 'customerMgtList',
        query:{
          urlActive:0,
        }
      })
    },
    handleCloseDialog() {
      this.$emit('update:visableIf', false);
      this.$emit('handleQuery');
    }
  }
}
</script>

<style scoped lang="scss">
.header-top {
  height: 46px;
  background: #fff;
  border-bottom: 1px solid #e9e9e9;
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 20px;

  .head-title {
    font-size: 14px;
    line-height: 22px;
    margin-right: 10px;
    display: flex;
    align-items: center;
    .backIcon {
      display: flex;
      align-items: center;
      padding: 0;
      margin-right: 12px;
      border: none;
      width: 24px;
      height: 24px;
      background: #4b5a95;
      border-radius: 12px;
      cursor: pointer;
      justify-content: center;
    }
    i {
      font-size: 16px;
      font-weight: bold;
      cursor: pointer;
      color: #fff;
    }
  }

}

.content-main {
  height: calc(100vh - 120px);
  overflow-y: auto;
  background: #fff;
  margin: 10px;
  .el-form {
    padding: 10px ;
  }
}

.userInfo {
  position: relative;
  background: #fff;
  padding: 16px;
  margin: 12px;
  padding-left: 100px;

  .user-img {
    width: 60px;
    height: 60px;
    position: absolute;
    left: 16px;
    top: 16px;

    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      border-radius: 4px;

    }
  }

  .user-name {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 0;
    line-height: 24px;
  }

  .user-unit {
    display: inline-block;
    font-size: 12px;
    color: #f90;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .label-list {
    label {
      font-size: 14px;
      line-height: 1.5715;
      word-wrap: break-word;
      font-weight: 400;
    }

    span {
      margin: 4px 4px 4px 0;
      font-size: 12px;
      height: 25px;
      line-height: 25px;
      white-space: nowrap;
      background: #f0f0f0;
      border: 1px solid #e9e9e9;
      border-radius: 4px;
      padding: 0px 7px;
      display: inline-block;

    }
  }
}

.chart {
  position: absolute;
  right: 20px;
  top: 20px;
}

.tablist {
  display: flex;
  height: 46px;
  align-items: center;
  background: #fff;
  border-bottom: 1px solid #eee;

  li {
    list-style: none;
    margin: 0 0 0 32px;
    cursor: pointer;
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;

    &.active {
      color: #3070ff;
      text-shadow: 0 0 .25px currentColor;

      &:after {
        content: '';
        position: absolute;
        bottom: 0px;
        width: 100%;
        height: 1px;
        background: #3070ff;

      }
    }
  }

}

.content-big {
  background: #fff;
  margin: 12px;
  min-height: 600px;
}
</style>
